<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
$intID = (int)$_data["ID"];
$strSQL = "select * from `bet_Lotto` where ID = ".$intID;
if(!$RS = @PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Find Lotto Data Error!!";
	ErrMsgOutputHTML("Error", "", 1);
}

if(PMA_mysql_num_rows($RS) == 0){
	@mysql_close($$_Conn);
	header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List");
	exit();
}else{
	$objLotto = PMA_mysql_fetch_object($RS);
}

if(!$_arrPermitTimeItems[$objLotto -> ID]){
	header("Location: ".basename($_SERVER["PHP_SELF"])."?op=List");
	exit();
}

$fp = @file($strTemplatePath."TimeItems.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);

$fp = str_replace("{intID}", $objLotto -> ID, $fp);
$strLo = "Lotto_".$_intLang;
$fp = str_replace("{ShowLotto}", $objLotto -> $strLo, $fp);

while(list($k, $v) = each($_strLotto)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

preg_match("/<!-- @ GameNo Start @ \/\/-->(.+)<!-- @ GameNo End @ \/\/-->/s", $fp, $arrMatch);

$arrTimeParam = unserialize($objLotto -> TimeParam);

$arrTimeRange = array(5 => 50, 6 => 23, 7 => 120, 8 => 84);

//兌換內容
$strCon = "";
for($intNo = 1; $intNo <= $arrTimeRange[$objLotto -> ID]; $intNo++){
	$strTmp = $arrMatch[1];
	/*if($arrTimeParam["GameTime"][$intNo] == ""){
		$arrTimeParam["GameTime"][$intNo] = date("H:i:s", mktime(10, $intNo*15 - 5, 0, 1, 1, 2000));
		$arrTimeParam["EndGameTime"][$intNo] = date("H:i:s", mktime(10, $intNo*15 - 5, 0, 1, 1, 2000));
	}*/
	$strTmp = str_replace("{ShowNo}", $intNo, $strTmp);
	$strTmp = str_replace("{ShowGameNo}", $intNo, $strTmp);
	$strTmp = str_replace("{ShowGameTime}", $arrTimeParam["GameTime"][$intNo], $strTmp);
	$strTmp = str_replace("{ShowEndGameTime}", $arrTimeParam["EndGameTime"][$intNo], $strTmp);
	$strCon .= $strTmp;
}
$fp = preg_replace("/<!-- @ GameNo Start @ \/\/-->.+<!-- @ GameNo End @ \/\/-->/s", $strCon, $fp);

//輸出
WebOutputHTML($fp, 1);
?>